/**
 * @fileOverview Graph插件
 * @author <a href="mailto:lexloo@126.com">lexloo</a>
 */
Gear.kernel.DefPlugIn('plugIns/graph/core.js', function() {
	var doc = document;
	var win = window;
	var math = Math;
	var PI = math.PI;

	Gear.Graph = {
		version : '1.0.0',
	};

	var GG = Gear.Graph;
	/**
	 * 图形类型
	 */
	GG.type = (win.SVGAngle || doc.implementation
			.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1")) ? "SVG" : "VML";
	
	
	GG.angle = function(x1, y1, x2, y2, x3, y3) {
		if (x3 == null) {
			var x = x1 - x2, y = y1 - y2;
			if (!x && !y) {
				return 0;
			}
			return ((x < 0) * 180 + math.atan(-y / -x) * 180 / PI + 360) % 360;
		} else {
			return GG.angle(x1, y1, x3, y3) - GG.angle(x2, y2, x3, y3);
		}
	};

	GG.rad = function(deg) {
		return deg % 360 * PI / 180;
	};

	GG.deg = function(rad) {
		return rad * 180 / PI % 360;
	};

	GG.canvas = document.createElement('div');
	GG.canvas.style.width = '100%';
	GG.canvas.style.height = '100%';
	GG.canvas.style.border = '1px solid red';
	
	if (GG.type === 'VML') {
		//Gear.kernel.loadPlugIn('plugIns/graph/vml.js');
	}
});